package com.happyrecyclingstation.config;

import com.happyrecyclingstation.interceptor.AdminTokenInterceptor;
import com.happyrecyclingstation.interceptor.HrTokenInterceptor;
import com.happyrecyclingstation.interceptor.JobSeekerTokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private JobSeekerTokenInterceptor JobSeekerTokenInterceptor;
    @Autowired
    private HrTokenInterceptor HrTokenInterceptor;
    @Autowired
    private AdminTokenInterceptor AdminTokenInterceptor;

    /**
     * 配置拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //  注册自定义拦截器
        registry.addInterceptor(JobSeekerTokenInterceptor).addPathPatterns("/jobSeeker/**");
        registry.addInterceptor(HrTokenInterceptor).addPathPatterns("/hr/**");
        registry.addInterceptor(AdminTokenInterceptor).addPathPatterns("/admin/**");
    }
}
